package com.woniuxy.member.app.apiImpl;

import com.woniuxy.cloud.mall95.log.Log;
import com.woniuxy.member.app.apiImpl.util.RequestUtil;
import com.woniuxy.member.client.MemberOrderQueryClient;
import com.woniuxy.orderService.client.CartQueryClient;
import com.woniuxy.orderService.client.OrderQueryClient;
import com.woniuxy.orderService.client.result.*;
import common.WoniuPage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import result.Result;

import java.util.List;

@RequestMapping("/member")
@RestController
public class MemberOrderQueryApiImpl implements MemberOrderQueryClient {
    @Autowired
    private CartQueryClient cartQueryClient;
    @Autowired
    private OrderQueryClient orderQueryClient;

    @Log("用户查询购物车")
    @Override
    public Result getCartByTableId() {

        Result<List<CartItemDto>> listResult = cartQueryClient.queryCart(RequestUtil.getStoreId(),RequestUtil.getTableId());
        return listResult;
    }
    @Log("用户查询订单")
    @Override
    public Result memberQueryStoreOrder() {
        Result<List<QueryStoreClientOrderDto>> listResult = orderQueryClient.queryStoreOrder(RequestUtil.getTableId());

        return listResult;
    }
    @Log("用户查询订单详情")
    @Override
    public Result memberQueryOrderItem(Integer orderId) {
        Result<List<OrderItemDto>> listResult = orderQueryClient.queryOrderItem(orderId);
        return listResult;
    }

    @Override
    public Result queryPayOrder(Integer pageNum, Integer pageSize) {
        Result<WoniuPage<PayOrderDto>> woniuPageResult = orderQueryClient.queryPayOrder(RequestUtil.getMemberId(), pageNum, pageSize);
        return woniuPageResult;
    }
}
